#include<iostream>
using namespace std;



class Solution {
public:
    void duplicateZeros(vector<int>& arr)
    {
        int len = arr.size();
        int cur = 0, dest = -1;
        while (cur < len)
        {
            if (arr[cur]) dest++;
            else dest += 2;
            if (dest >= len - 1) break;

            cur++;

        }
        if (dest >= len)
        {
            arr[len - 1] = 0;
            cur--;
            dest -= 2;
        }
        while (cur >= 0)
        {
            if (arr[cur])
            {
                arr[dest--] = arr[cur--];
            }
            else
            {
                arr[dest--] = 0;
                arr[dest--] = 0;
                --cur;
            }
        }
    }
};
int main()
{

	return 0;
}
